/*
 * @Description: 
 * @Author: 赵华宇
 * @Date: 2024-11-07 10:36:11
 * @LastEditors: 赵华宇
 * @LastEditTime: 2024-11-07 11:29:45
 */
var arr=new Array(1,2,3,"4",true,[124,125]);
var arr1=[1,2,3];
console.log("🚀 ~ arr[0]:", arr[0]);
console.log("🚀 ~ arr.length:", arr.length);
arr[10]=10;
console.log("🚀 ~ arr.length:", arr.length);
console.log("🚀 ~ arr[9]:", arr[9]);
//追加元素
arr.push('a','b');
//删除元素 索引开始位置 删除的元素个数
arr.splice(0,2);
//遍历数组
for(var i=0;i<arr.length;i++){
    console.log("🚀 ~ i:", arr[i]);
    console.log('arr['+i+']' +arr[i]);
}
// arr.forEach(function(item){
//     console.log("🚀 ~ arr.forEach ~ item:", item);
// }
// )
arr.forEach(
    // 箭头函数
    (item) => {
      console.log('🤡 CC => item:', item);
    }
  );  
// var fun1 = function (item) {
//   console.log('🤡 CC - arr.forEach - item:', item);
// }
// arr.forEach(fun1);
var str = new String("hello");
console.log("🚀 ~ str:", str);
console.log('🤡 CC - str.length:', str.length);
var str2 = "hello";
console.log("🚀 ~ str2:", str2);
onsole.log('🤡 CC - str2.length:', str2.length);
var stu1={
    //属性
    name:"张三",
    age:10,
    gender:"男",
    likes:["篮球","足球"],
    //方法
    eat:function(){
        console.log("吃饭");
    }
}
console.log("🚀 ~ stu1.name:", stu1.name);
stu1.eat();

